using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class SkeletonMoveState : SkeletonGroundedState
{
    public SkeletonMoveState(Enemy _enemyBase, EnemyStateMachine _enemyStateMachine, string _animBoolName, Enemy_Skeleton enemy) : base(_enemyBase, _enemyStateMachine, _animBoolName, enemy)
    {
    }

    public override void Enter()
    {
        base.Enter();
        
    }

    public override void Exit()
    {
        base.Exit();
    }

    public override void Update()
    {
        base.Update();

        //Debug.Log("I am Moving with "+enemy.rb.velocity);
        enemy.SetVelocity(enemy.moveSpeed * enemy.facingDir, rb.velocity.y);
        //enemy.rb.velocity = new Vector2(enemy.moveSpeed * enemy.facingDir, rb.velocity.y);

        if(enemy.IsWallDetected() ||  !enemy.IsGroundDetected()) 
        {
            enemy.Flip();
            stateMachine.ChangeState(enemy.idleState);
        }
    }
}
    

